package MyStack;

import java.util.Iterator;
import java.util.Map;



public class HashMap {
	public static void main(String[] args) {
		
		Map Teaching = new java.util.HashMap<>();
		 Teaching.put("tom","java");
		 Teaching.put("john", "oracle");
		 Teaching.put("alice", "jsp");
		 Teaching.put("lucy", "jsp");
		 Teaching.put("jim", "linux");
		 Teaching.put("allen","ssm");
		 Teaching.replace("lucy", "java");
		 
		 Iterator it =Teaching.entrySet().iterator();
		 while(it.hasNext()) {
			 Map.Entry entry =(Map.Entry)it.next();
			 System.out.println(entry.getKey()+" "+entry.getValue());
			 
		 }
		 System.out.println("\nTeachers who teach jsp list");
		 it =Teaching.entrySet().iterator(); //notice initialize again!
		 while(it.hasNext()) {
			 Map.Entry entry =(Map.Entry)it.next();

			 if(entry.getValue().equals("jsp")) {
				 System.out.println(entry.getKey()+" "+entry.getValue());
			 }
		 }
		

	}

}
